package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrderPageQueryDTO;
import com.sky.entity.Category;
import com.sky.entity.Orders;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface OrdersMapper {
    void insert(Orders orders);

    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    /**
     *   * 历史订单查询
     * @param orderPageQueryDTO
     * @return
     */
    @Select("  select * from orders")
    Page<Category> pageQuery(OrderPageQueryDTO orderPageQueryDTO);

    @Delete("delete from orders where id = #{id}")
    void cancel(Long id);

    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void oneMoreOrder(Long id);


    /**
     * 取消订单
     * @param orders
     */
    void updateCancelOrder(Orders orders);

}
